﻿using Dapper;
using SetSailModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SetSailDal
{
    public class XXBGDal
    {
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static ResultModel<int> EditPWD(string ID, string DLMM)
        {
            ResultModel<int> res = new ResultModel<int>();
            try
            {
                string sql = string.Format(@"UPDATE QH_YHXX
                                                SET DLMM = '{0}' WHERE ID='{1}'", DLMM, ID);
                using (DBHelper help = new DBHelper())
                {
                    res.Count = help.DbContext.Execute(sql);
                    if (res.Count == 0)
                    {
                        res.Code = ResultCode.Fail;
                        res.Message = "密码修改失败";
                    }
                    else
                    {
                        res.Message = "密码修改成功";
                    }
                }
            }
            catch (Exception ex)
            {
                res.Code = ResultCode.Exception;
                res.Message = ex.Message;
            }
            return res;
        }

        /// <summary>
        /// 修改个人信息
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static ResultModel<int> EditYHXX(SetSailModel.QH_YHXX user)
        {
            ResultModel<int> res = new ResultModel<int>();
            try
            {
                string sql = string.Format(@"UPDATE QH_YHXX
                                                SET QQ = '{0}',YY='{1}',ZBFJH='{2}',DDLX='{3}',ZBFS='{4}' WHERE ID='{5}'", user.QQ, user.YY, user.ZBFJH, user.DDLX, user.ZBFS, user.ID);
                using (DBHelper help = new DBHelper())
                {
                    res.Count = help.DbContext.Execute(sql);
                    if (res.Count == 0)
                    {
                        res.Code = ResultCode.Fail;
                        res.Message = "修改失败";
                    }
                    else
                    {
                        res.Message = "修改成功";
                    }
                }
            }
            catch (Exception ex)
            {
                res.Code = ResultCode.Exception;
                res.Message = ex.Message;
            }
            return res;
        }
    }
}
